package sctu.edu.java.year2016.team08.lisonghong.day20160616.chapter17_2;

/**
 * Created by 松红 on 2016/6/16.
 * 用java创建一个表格！
 */

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;

public class JTable extends JFrame {
    public JTable() {
        super();
        setTitle("创建可以滚动的表格！");
        setBounds(100, 100, 240, 150);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        String[] columnNames = {"A", "B"};
        String[][] tableValues = {{"B", "A"}, {"B2", "A2"}, {"B2", "A2"}, {"B2", "A2"}, {"B2", "A2"}, {"B2", "A2"}, {"B2", "A2"}, {"B2", "A2"}, {"B2", "A2"}, {"B2", "A2"}};
        javax.swing.JTable table = new javax.swing.JTable(tableValues, columnNames);
        JScrollPane scrollPane = new JScrollPane(table);
        getContentPane().add(scrollPane, BorderLayout.CENTER);
        setVisible(true);

    }


    public static void main(String[] args) {
        // TODO Auto-generated method stub

        new JTable();
    }

}